package July;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Day0718 {
    //求最小公倍数
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){
            int a = scanner.nextInt();
            int b = scanner.nextInt();

            for (int i = 1; i <= a*b ; i++) {
                if (i%a == 0 && i%b == 0){
                    System.out.println(i);
                    break;
                }
            }
        }
    }


    //两种排序方法
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            String[] strings = new String[n];
            for (int i = 0; i < n; i++) {
                strings[i] = scanner.next();
            }

            if (Len(strings) && Set(strings))
                System.out.println("both");
            else if (Len(strings) == true && Set(strings) == false)
                System.out.println("lengths");
            else if (Len(strings) == false && Set(strings) == true)
                System.out.println("lexicographically");
            else
                System.out.println("none");
        }
    }

    //根据字符集
    private static boolean Set(String[] strings) {
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < strings.length; i++) {
            arrayList.add(strings[i]);
        }
        Collections.sort(arrayList);
        String[] strings1 = new String[strings.length];

        for (int i = 0; i < strings1.length; i++) {
            strings1[i] = arrayList.get(i);
        }
        for (int i = 0; i < strings1.length; i++) {
            if (strings[i] != strings1[i])
                return false;
        }
        return true;
    }

    //根据长度
    private static boolean Len(String[] strings) {
        int length = strings[0].length();
        for (int i = 1; i < strings.length; i++) {
            if (length <= strings[i].length())
                length = strings[i].length();
            else
                return false;
        }
        return true;
    }
}
